package com.ZengQi.event.controller;

import com.ZengQi.event.entity.Finish;
import com.ZengQi.event.entity.Topic;
import com.ZengQi.event.service.FinishService;
import com.ZengQi.event.service.TopicService;
import com.ZengQi.event.service.impl.FinishServiceImpl;
import com.ZengQi.event.service.impl.TopicServiceImpl;

public class AnswerTopicViewController {
    private TopicService topicService=new TopicServiceImpl();
    private FinishService finishService=new FinishServiceImpl();

    public boolean isRight(Topic conditionTopic,String finisher){
       Topic topic=topicService.findListTopic(conditionTopic).get(0);
       if (topic.getTopicAnswer().equals(conditionTopic.getTopicAnswer())){
           Finish finish=new Finish();
           finish.setFinisher(finisher);
           finish.setFinishStatus("正确");
           finish.setTopicName(topic.getTopicName());
           finishService.saveFinish(finish);
           return true;
       }else {
           Finish finish=new Finish();
           finish.setFinishStatus("错误");
           finish.setFinisher(finisher);
           finish.setTopicName(topic.getTopicName());
           finishService.saveFinish(finish);

           return false;
       }

    }
}
